home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1990 May & June & July
/
rerun-1990-05-06-07.d64
/
assembly lang.ut
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
5KB
|
137 lines
10 rem :: assembly language utility
20 rem :: by eric jevon bryant
30 poke53280,0:poke53281,0:printchr$(5);:gosub1250:mn=1:a=1
40 rem :: main menu
50 op=-1:x=1:gosub1110:onmn-1goto60,320,540,810
60 rem :: conversions
70 cc=0:qi=-5*(x=2)+-4*(x=3)+-3*(x=4)+-8*(x=5):onx-1goto80,140,200,270
80 rem : decimal to hex
90 print"decimal number: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
100 de=val(cc$(0)):ifde<0orde>65535thenprint"invalid number":print:goto90
110 gosub120:print"hex conversion: $";h$:print:goto80
120 h$="":forx=3to0step-1:x%=de/(16^x):de=de-x%*16^x:h$=h$+mid$(he$,x%+1,1)
130 next:return
140 rem : hex to decimal
150 print"hex number--------: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
160 gosub170:print"decimal conversion:";de:print:goto140
170 d=0:q=3:forx=1to4:fory=0to15:ifmid$(cc$(0),x,1)=mid$(he$,y+1,1)then190
180 nexty
190 z=y*(16^(q)):d=d+z:q=q-1:nextx:de=int(d):return
200 rem : decimal to binary
210 print"decimal number---: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
220 de=val(cc$(0)):ifde<0orde>255thenprint"invalid number":print:goto210
230 gosub240:print"binary conversion: ";b$:print:goto210
240 b$="":y=128:forx=1to8:ifde>=ythende=de-y:b$=b$+"1":goto260
250 ifde<ythenb$=b$+"0"
260 y=y-y/2:nextx:return
270 rem : binary to decimal
280 print"binary number:----: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
290 gosub300:print"decimal conversion:";de:print:goto270
300 y=128:de=0:forx=1to8:ifmid$(cc$(0),x,1)="1"thende=de+y
310 y=y-y/2:nextx:return
320 rem :: change memory
330 qi=5:de=0:onx-1goto340,400
340 rem : change location
350 x$="starting address":mx=65535:n=0:ln=-1:gosub1030:ad=x:ln=0
360 ifqtthenop=-1:a=2:lm=1:mn=3:goto50
370 qi=3:x$="poke"+str$(ad):mx=255:n=-1:gosub1030:ifqtthen390
380 pokead,x:ad=ad+1:goto370
390 print:print"ending address:";ad:poke198,0:wait198,1:a=3:goto360
400 rem : insert message
410 print"input message:":qi=255:cc=1:gosub860:a=cc:println$;:cx=0:cy=5
420 x$="starting address":mx=65535:n=0:ln=0:cc=0:gosub1030:ad=x
430 print"output as (a)scii or (s)creen code: ";:cc=0:gosub880
440 ifqtthenmn=3:lm=1:a=2:op=-1:goto50
450 x$=left$(cc$(0),1):pt=-1*(x$="a")+-2*(x$="s"):ifpt=0thengoto430
460 println$:print"please wait....":forx=1to500:next:op=0:mn=3:x=3:gosub1110
470 forx=1toa:fory=1tolen(in$(x)):ifpt=1thennp=asc(mid$(in$(x),y,1)):goto480
480 b=y:printchr$(19);:sc=peek(646):poke646,peek(53281):printmid$(in$(x),y,1)
490 ifcy=22thency=5:cx=notcxand17:ifcx=0thena=x:op=0:mn=3:x=3:gosub1110:x=a:y=b
500 poke781,cy:poke782,cx:poke783,0:poke646,sc:cy=cy+1:sys65520
510 ifpt=2thennp=peek(1024)
520 print"poke";ad;",";np:pokead,np:ad=ad+1:nexty,x:print
530 print"ending address:";ad-1:poke198,0:wait198,1:qt=-1:goto440
540 rem :: examine memory
550 lm=1:qi=5:onx-1goto560,720
560 rem : examine locations
570 x$="starting address":mx=65535:ln=-1:gosub1030:ad=x
580 ifqtthenop=-1:mn=4:a=2:lm=1:goto50
590 forx=1to500:next:mn=6:op=-1:a=2:lm=4:x=1:gosub1110:md=x-1
600 ifmd=4thenprintchr$(peek(ad));:goto620
610 printad;":";:gosub650:ad=ad+1:printtab(15);ad;":";:gosub650:print:gosub700
620 geta$:ifa$=""thenad=ad+1:goto600
630 ifa$=chr$(133)thenqt=-1:goto580
640 poke198,0:wait198,1:poke198,0:goto600
650 de=peek(ad):ifmd=1thenprintde;:return
660 y=1:onmdgosub660,120,240
670 ifmd=2thenprinth$;
680 ifmd=3thenprintb$;
690 return
700 ifpeek(214)=23thenmn=6:a=2:op=0:x=z+1:gosub1110
710 return
720 rem : test bits
730 x$="object address":mx=65535:ln=-1:gosub1030:ad=x:print"value:";peek(ad);
740 ifqtthenmn=4:a=2:x=1:goto50
750 ad$=str$(ad):ad$=right$(ad$,len(ad$)-1)
760 print:de=peek(ad):forx=0to7:bt$(x)=mid$(str$(x),2,1):nextx:printad$;":";
770 printtab(8);:gosub240:forx=1to8:ifmid$(b$,9-x,1)="1"thenprintchr$(18);
780 printbt$(x-1);spc(3);chr$(146);:next:de=ad:gosub120:print"$";h$;":";spc(1);
790 forx=1to8:of$="off":ifmid$(b$,9-x,1)="1"thenof$=" on"
800 printof$;spc(1);:next:print:println$;:goto720
810 rem :: exit utility
820 rem : break into monitor
830 ifx=2thenpoke53280,11:poke53281,11:poke2,0:sys2
840 rem : quit utility
850 end
860 rem :: parser
870 forx=0tocc:in$(x)="":next
880 in$(0)="":qt=0:zl=0:zt=ti:zc=2:zd$=chr$(20):wd=40:cr$=chr$(13)
890 getz$:ifz$<>""then920
900 print"[164]"+chr$(157);
910 goto890
920 z=asc(z$):zl=len(in$(cc)):ifz=20thenprint" "+chr$(157);:goto950
930 ifzl=qithenifcc=1000thenreturn
940 ifz=13thenprintchr$(32);chr$(20);:ifcc=0thencc$(0)=in$(0):print:return
950 ifz=133thenprintchr$(28);"escape";cr$;chr$(5);:qt=-1:return
960 ifz=20andzl=0then890
970 ifz=20thenin$(cc)=left$(in$(cc),zl-1):printchr$(20);:goto890
980 ifz=134thenprint:ad=-1:gotoreturn
990 ifzl=qithenifcc=0then890
1000 ifzl=qithencc=cc+1
1010 in$(cc)=in$(cc)+z$:printz$;
1020 goto890
1030 rem :: input starting address
1040 printx$;": ";:gosub880:x=val(cc$(0)):ifqtthenreturn
1050 ifleft$(cc$(0),1)="$"thencc$(0)=right$(cc$(0),len(cc$(0))-1):z=1
1060 if(z=1)andnthencc$(0)="00"+cc$(0)
1070 ifz=1thengosub170:x=de
1080 if(x<0orx>mx)or(z=1andx=0)thenprint"invalid address":print:goto1040
1090 iflnthenprintln$;
1100 n=0:return
1110 rem :: menu plotting
1120 printchr$(147);tab(8);"assembly language utility":println$;:poke198,0
1130 y=2:printspc(19-(len(mn$(mn,x))/2));mn$(mn,x):println$:ifnotopthenreturn
1140 x$=str$(x):x$=right$(x$,1):printx$;">";chr$(32);mn$(mn,1+x):print
1150 x=x+1:y=y+1:ifx=5then1180
1160 ifmn$(mn,y)="*"then1180
1170 goto1140
1180 geta$:ifa$=""then1180
1190 ifa$=chr$(133)andmn<>1thena=a+1*(mn<>6):mn=lm:x=1:lm=1:goto1240
1200 z=val(a$):if(z=0)or(z=>x)then1180
1210 a=a+1:printchr$(19);:forx=1toz*2+1:print:next:printtab(3);chr$(18);
1220 printmn$(mn,z+1);chr$(146):forx=1to500:next:lm=mn:b=mn:mn=z+1:x=1
1230 ifmn<>1anda=3thenop=0:mn=b:x=z+1
1240 gosub1110:return
1250 rem :: initiation
1260 dimmn$(6,5)
1270 forx=1to6:fory=1to5:readmn$(x,y):nexty,x:he$="0123456789abcdef"
1280 forx=1to40:ln$=ln$+chr$(192):next:return
1290 data main menu,conversions,change memory,examine memory,exit utility
1300 data conversions,decimal to hex,hex to decimal,decimal to binary
1310 data binary to decimal
1320 data change memory,change locations,insert message,*,*
1330 data examine memory,examine location,examine bits,*,*
1340 data exit utility,break into monitor,quit utility,*,*
1350 data choose method of output,decimal values,hex values,binary values
1360 data asc ii code